<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>div</div>
    <script>
        window.addEventListener('popstate', (event) => {
            console.log("location: " + location + ", state: " + JSON.stringify(event.state));
        });
        /**
         * popstate是对接口进行访问的事件
         * history.go()===>window.reload()
         * history.back() ==> history.go(-1)
         * history.forward() ==> history.go(1)
         * 触发该事件的三种情况
         * 1.点击浏览器前后箭头/js调用history.go(num)
         * 2.设置hash值触发
         * 
        */
        let path = location.pathname;
        history.replaceState({path:path},'',path)
        //replaceState(jsObject,title[多数浏览器忽略此参数],url)
    </script>
</body>
</html>